package com.burgeon.backend.SHOP.rest;

/**
 * 修改vip专属导购
 */

import com.burgeon.backend.Rest.base.RESTBase;
import org.json.JSONArray;
import org.springframework.util.MultiValueMap;

import java.util.HashMap;

public class ModRefundRET_State extends RESTBase {

    private String ip;
    private String account;
    private String password;

    public ModRefundRET_State(String ip, String account, String password) {
        this.ip = ip;
        this.account = account;
        this.password = password;
    }

    /**
     * 发送并接收字符创
     */

    public void getData(String id,String table, String state) throws Exception {

        String url = "http://" + ip + "/servlets/binserv/Rest";
        String str = RESULT(Data(id,table, state), url);
        System.err.println(str);
        String code = new JSONArray(str).getJSONObject(0).getString("code");
        String message = new JSONArray(str).getJSONObject(0).getString("message");
        if (!"0".equals(code)) {
            throw new Exception(message);
        }
    }

    private MultiValueMap Data(String id,String table, String state) {

        HashMap params = new HashMap();

        params.put("ID", id);
        params.put("partial_update", "true");

        params.put("table", table);//表名


        params.put("'YC_RET_STATUS'",state);

        return DATA("ObjectModify", params, account, password);
    }

    public static void main(String[] args) {
        ModRefundRET_State g = new ModRefundRET_State("59.110.28.94:90", "nea@burgeon.com.cn", "burgeon55321");
        try {
           g.getData("10","YC_V5_RET_RETAIL","6");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
